package com.yuexun.beilunpatient.ui.consult.presenter.impl;


import com.yuexun.beilunpatient.ui.consult.bean.MailFileBean;
import com.yuexun.beilunpatient.ui.consult.model.IHelpModel;
import com.yuexun.beilunpatient.ui.consult.presenter.IHelpPresent;
import com.yuexun.beilunpatient.ui.consult.ui.view.IHelpView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/3/15 0015.
 */

public class HelpPresent implements IHelpPresent {

    private IHelpModel model;
    private IHelpView view;

    public HelpPresent(IHelpModel model, IHelpView view){
        this.model = model;
        this.view= view;
    }


    @Override
    public void getFileData(Map<String, String> praise) {
        model.getFileData(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<MailFileBean>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取附件信息失败");
                    }

                    @Override
                    public void onNext(MailFileBean mailFileBean) {
                        view.getFileData(mailFileBean);
                    }
                });
    }

}
